
import com.mysql.jdbc.Statement;
import java.sql.ResultSet;


public class UsuarioDAO extends Base {
    
    //<editor-fold defaultstate="collapsed" desc="Contrutor">
    public UsuarioDAO(){
        
    }
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="Métodos">
    public boolean logar(Usuario usuario){
      conectarBanco();
      String sql;
      try{
            sql = "SELECT * FROM tb_usuario WHERE login = '"+usuario.getLogin()+"'"
                    + " AND senha = '"+usuario.getSenha()+"' AND nivel_acesso = '"+usuario.getNivelAcesso()+"';";
            // System.out.println(sql);

            Statement st = (Statement) c.createStatement();
            ResultSet rs = st.executeQuery(sql);

            if (rs.next()
                    && rs.getString("login").equals(usuario.getLogin())
                    && rs.getString("senha").equals(usuario.getSenha())
                    && rs.getString("nivel_acesso").equals(usuario.getNivelAcesso())) {
                //Usuario obj = new Usuario(rs.getString("nivel_acesso"));
              //  usuario.setNivelAcesso(rs.getString("nivel_acesso"));
                return true;
            }
            return false;
        }catch (Exception e) {
        System.out.println(e);
        return false;
    }
  }
    //</editor-fold>
    
}
